<?php
use yii\helpers\Html;
use common\modules\system\models\Menu;
use common\helpers\Constants;
use common\helpers\TreeHelper;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\modules\system\models\Menu */
/* @var $form yii\widgets\ActiveForm */

$category = $model->category_id;

$menus = Menu::getArrayTree($category);

$options = TreeHelper::buildTreeOptionsForSelf($menus, $model);

?>
<p>
    <?= Html::a('返回', ['index','category'=>$category], ['class' => 'btn btn-primary'])?>
</p>
<?php $form = ActiveForm::begin(); ?>
    <div class="da-form-row">
    	<label>父结点</label>
    	<div class="da-form-item small">
                <?php echo Html::activeHiddenInput($model, 'category_id')?>
                <select type="text" id="menu-parent_id" class="form-control"
    			name="Menu[parent_id]">
                <?php echo $options?>
                </select>
    	</div>
    </div>

    <?= $form->field($model, 'name')->textInput(['maxlength' => 64]) ?>

    <?= $form->field($model, 'url')->textInput(['maxlength' => 512]) ?>

    <?= $form->field($model, 'target')->radioList(Constants::getTargetItems()) ?>

    

    <?= $form->field($model, 'icon')->textInput() ?>
    <?= $form->field($model, 'description')->textarea(['maxlength' => 512]) ?>

    

    <?= $form->field($model, 'sort')->input('number') ?>
    
    <?= $form->field($model, 'status')->radioList(Constants::getStatusItems()) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
    </div>
<?php ActiveForm::end(); ?>
